In [1]:
%matplotlib inline
import nengo
import numpy as np
import pylab

Using Nengo to define a model to be run with a different simulator

This is meant as an example script to take a standard Nengo model and extract out the information needed to simulate it outside of Nengo. When developing a new backend, we often use this as a first step to figure out the process that would need to be automated.

Step 1: Define the model


In [2]:
model = nengo.Network()
with model:
    def stim_a_func(t):
        return np.sin(t*2*np.pi)
    stim_a = nengo.Node(stim_a_func)
    a = nengo.Ensemble(n_neurons=50, dimensions=1)
    nengo.Connection(stim_a, a)
    
    def stim_b_func(t):
        return np.cos(t*np.pi)
    stim_b = nengo.Node(stim_b_func)
    b = nengo.Ensemble(n_neurons=50, dimensions=1)
    nengo.Connection(stim_b, b)
    
    c = nengo.Ensemble(n_neurons=200, dimensions=2, radius=1.5)
    nengo.Connection(a, c[0])
    nengo.Connection(b, c[1])
    
    d = nengo.Ensemble(n_neurons=50, dimensions=1)
    
    def multiply(x):
        return x[0] * x[1]
    nengo.Connection(c, d, function=multiply)

    data = []
    def output_function(t, x):
        data.append(x)
    output = nengo.Node(output_function, size_in=1)
    nengo.Connection(d, output, synapse=0.03)

Step 2: Run it in normal Nengo


In [3]:
sim = nengo.Simulator(model)
sim.run(2)

pylab.plot(data)


Simulation finished in 0:00:02.                                                 
Out[3]:
[<matplotlib.lines.Line2D at 0xa874860>]

Step 3: Extract data about groups of neurons


In [4]:
for ens in model.all_ensembles:
    print('Ensemble %d' % id(ens))
    print('    number of neurons: %d' % ens.n_neurons)
    print('    tau_rc: %g' % ens.neuron_type.tau_rc)
    print('    tau_ref: %g' % ens.neuron_type.tau_ref)
    print('    bias: %s' % sim.data[ens].bias)


Ensemble 54978880
    number of neurons: 50
    tau_rc: 0.02
    tau_ref: 0.002
    bias: [  5.36301911e-01   6.35003357e+00  -1.68604461e+02   1.84899177e+00
   3.30085928e+00  -1.80561722e+01   1.04969542e+01  -4.00247132e+00
   1.93608842e+00  -1.65907986e+02  -1.90784389e+00   3.07432809e+00
   5.99176287e+00   6.51427013e+00   1.53497626e-01   1.50899425e+00
  -4.55871462e+00  -2.98739162e+01   3.61266298e+00   8.21982406e-01
  -1.77936838e+02  -3.63134719e+00   1.06216064e+01   2.38301439e+00
  -3.15011763e+01   5.90426199e+00   6.21281935e+00  -2.73467062e+01
   7.11055550e+00  -8.79765786e+01  -1.61631915e+01   4.70228795e+00
   6.59597395e+00   1.60831884e+00   1.06933341e+01   9.54774709e+00
   7.99108390e+00  -3.39117756e+02  -2.67361662e+01  -1.32731163e+02
  -8.55889037e-01  -7.49063115e+00   1.31636585e+00   1.02467507e+01
  -9.77894544e+01   2.74869475e+00   3.98249124e+00  -2.10870693e+01
   5.23838511e+00  -5.31936919e+00]
Ensemble 31828792
    number of neurons: 50
    tau_rc: 0.02
    tau_ref: 0.002
    bias: [ -8.36527128e+00  -3.79388690e+00   6.62994696e+00  -7.41501787e+01
   3.91722746e+00  -7.17231417e+02   4.41099487e+00   7.92105865e+00
   1.90565827e+00   9.90085360e-01   2.41808389e-01  -1.59338170e+00
  -1.88612735e+01  -4.07373991e+01   6.87594463e+00   7.49454704e-03
   3.05096770e+00  -3.20702903e+02  -1.56512959e+03   1.41557733e+00
  -5.03355762e+00  -8.51695607e+01   3.25602057e+00   7.84249344e+00
   7.79339849e+00   1.67340820e+00  -1.80965604e+02   5.69268842e+00
   1.59583429e+01  -5.69607316e+00   3.90357748e+00  -1.06835442e+00
   7.02548352e+00   5.10746933e+00   1.32298705e+00   4.74338393e+00
   1.13641103e+01  -6.62405627e+01   5.10935059e+00   1.41954246e+01
  -1.64324816e+02   5.52837102e+00   3.57377024e+00   1.15922499e+00
  -2.05721641e+02   4.70384374e+00  -1.34171336e+02   3.64093881e+00
  -3.89241661e+00  -4.94403400e+01]
Ensemble 169475264
    number of neurons: 200
    tau_rc: 0.02
    tau_ref: 0.002
    bias: [ -1.06546027e+00   1.17851901e+00  -3.70245609e+01   3.58155755e+00
   5.85582820e+00   3.04883043e+00   1.08123548e+01  -7.13293916e+00
  -1.84561633e+02  -4.47693970e+00  -4.56224268e+01  -5.98538064e+00
  -1.88906038e+01   3.67945541e+00  -5.89212175e+01  -5.92552744e+01
   2.17507310e+00  -3.17632762e+01   9.90217954e-01   4.03107732e+00
  -1.14023384e+01   1.88675698e+00   7.46137085e+00   5.26296059e+00
  -1.24715786e+01  -4.15555597e+00  -3.52353116e-01  -2.63124120e+01
   2.67348537e+00  -2.32661056e+01   3.10032881e+00  -1.54299744e+02
   2.22615348e+00   4.05903848e+00  -4.31912404e-01   8.55781231e+00
   8.84002849e+00   4.08796704e+00   7.53582930e+00  -6.21699825e-01
   1.88879439e+01  -7.41765685e-01   7.83756946e+00  -8.42058662e+00
  -1.48773584e+02   3.59004059e+00  -9.66579119e+02   8.55420167e+00
   4.05356039e+00  -4.82666664e+01   4.80209305e+00   2.89159370e-01
  -5.41019061e+00   8.35869659e+00  -2.09094553e+00   4.25526497e+00
  -1.27234115e+01   3.80904994e+00   1.25254403e+01  -1.92931600e+01
  -6.00425376e+01  -8.64210259e-01   8.07904350e+00  -1.19009198e+00
   5.99606248e+00  -2.40742344e+02   6.48199035e+00   2.36678949e+00
   5.03778848e+00  -3.40924481e+00  -2.80467299e+01  -1.17589152e+01
  -2.20205696e+01  -1.43832486e+01  -5.68828157e+00  -4.70845505e+01
  -4.80059943e+01   4.23671984e+00   3.26099486e+00   5.00691540e-02
   1.10122844e+01  -4.39819037e+01  -1.53767625e+02  -3.03735383e+00
   4.29985480e+00  -4.02812102e-01   8.83829252e+00  -5.46001773e+02
   4.63548252e-01  -6.52044714e+02   5.70049927e+00   4.65396354e+00
   3.09099234e+00   1.86540188e+00  -4.67536594e+00  -1.47120971e+01
   9.52080577e+00  -1.13118296e+03   1.18178796e+01  -2.01153723e+00
  -1.17408432e+01   5.12341535e+00   5.78072807e+00  -9.28109020e+00
   1.00365194e+00  -1.57150169e+01  -7.66705291e+00   4.63684446e+00
  -2.73815739e+00  -1.16732100e+01  -4.31102690e+00  -2.39044092e+01
   7.03336874e+00  -6.37667633e+01  -3.27470366e+01  -3.16358607e+00
   1.59456758e+01  -5.67954697e+01   9.49914102e-01   1.09572742e+01
  -2.19332158e+01   3.40780173e+00  -2.73261445e-01   2.09625795e+00
  -3.92933079e+00   5.30314815e-01  -1.47534081e+02  -1.69652337e+02
   9.35500446e+00  -3.41647175e+00  -2.59822070e+00   1.81863808e+00
  -7.34758561e-01   1.17961912e+01  -5.97037572e+01   1.14261990e+01
  -1.44262256e+00  -8.23117090e+01   1.88220113e+01  -6.32484122e+01
  -7.50836400e+00   1.21681327e+01   3.98351268e+00   4.39896278e+00
  -2.13640671e+00   5.21506945e+00  -1.25572249e+02   7.29264454e+00
   5.57655872e+00  -1.91499780e+01   1.33019705e+01   3.26261619e+00
  -1.60026623e+01   5.12695269e+00  -4.27291214e-01   1.91541109e+00
  -1.16551225e+00   3.17981317e+00  -1.69748325e+01  -2.29974803e+01
   1.27040502e+01  -3.44072450e+00  -1.85912658e+00   2.45403979e+00
  -8.95110672e+00   9.51488804e-01   4.25473915e+00  -2.16392818e+01
  -1.27358650e+02  -1.35267857e+01  -6.83584765e+00  -5.73629432e+01
  -2.47115196e+01   7.76354735e+00   5.46603196e+00   7.33729031e+00
   9.41191422e+00  -7.62091193e+01   5.91206197e+00  -6.50266354e+03
   7.84220920e+00   6.60666534e+00   6.41721628e+00   2.13406858e+00
   8.65694155e+00   9.56273057e+00   1.58892641e+01   1.16920545e+01
   4.71268173e+00   9.40823961e+00   3.88374662e+00  -7.22255693e-01
   5.81862626e+00   5.84828928e+00   7.69825441e-01  -1.69934890e+00
  -1.42406277e+01   7.02305582e+00   8.75497960e+00   2.27501847e+00]
Ensemble 169475600
    number of neurons: 50
    tau_rc: 0.02
    tau_ref: 0.002
    bias: [ -4.29121968e+00   1.22114255e+01   1.27295132e+01   8.07506719e+00
   9.34068030e+00   4.44141712e+00   4.59363131e+00  -3.68097148e+01
   8.76465665e+00   1.54954775e+00  -5.65485212e+00   5.36045248e+00
  -3.74254639e+02  -6.20018523e+03   2.86448082e+00  -2.49122357e+00
   4.50866214e+00   7.82115072e+00  -6.84244052e+00   8.69795952e+00
   8.38177426e+00   1.33133832e+01   2.92187141e+00   3.26111101e+00
  -1.32619995e+01  -8.83384103e+00  -2.51447817e+00  -7.36822740e-01
  -3.59297876e+02  -3.83510404e+00   1.60571743e-01   1.26556488e-01
   5.77922110e+00  -8.00984061e+00   2.51803190e+00   5.08304857e+00
   2.10483811e+00  -4.50713673e+01   6.14158224e+00  -6.93089717e+01
  -1.73107475e+01   1.01149892e+01  -1.69161068e+00  -4.90564216e-01
   1.15280544e+01   9.10205767e+00  -1.25024968e+02   5.32249982e+00
   8.05182317e+00   1.28520776e+01]

Step 4: Extract data about inputs


In [5]:
for node in model.all_nodes:
    if node.size_out > 0:
        print('Input node %d' % id(node))
        print('Function to call: %s' % node.output)


Input node 169474592
Function to call: <function stim_a_func at 0x000000000A1959E8>
Input node 7571104
Function to call: <function stim_b_func at 0x0000000001E5EB38>

Step 5: Extract data about outputs


In [6]:
for node in model.all_nodes:
    if node.size_in > 0:
        print('Output node %d' % id(node))
        print('Function to call: %s' % node.output)


Output node 169475768
Function to call: <function output_function at 0x000000000A195A58>

Step 6: Extract data about connections between Ensembles


In [7]:
for conn in model.all_connections:
    if isinstance(conn.pre_obj, nengo.Ensemble) and isinstance(conn.post_obj, nengo.Ensemble):
        print('Connection from %d to %d' % (id(conn.pre_obj), id(conn.post_obj)))
        print('    synapse time constant: %g' % conn.synapse.tau)        
        decoder = sim.data[conn].weights
        transform = nengo.utils.builder.full_transform(conn, allow_scalars=False)
        encoder = sim.data[conn.post_obj].scaled_encoders
        print('    decoder: %s' % decoder)
        print('    transform: %s' % transform)
        print('    encoder: %s' % encoder)


Connection from 54978880 to 169475264
    synapse time constant: 0.005
    decoder: [[ -7.19633169e-05  -1.78741484e-04   6.46361094e-05  -1.11256403e-04
    1.25990977e-04   6.38863978e-05  -2.38751459e-04  -7.56944887e-05
   -1.12044869e-04   4.57887721e-05  -8.17143547e-05  -1.73650322e-04
    1.40837307e-04   1.54240417e-04  -6.85479733e-05  -1.09674639e-04
   -8.42420730e-05  -8.26932022e-05  -1.89643076e-04   2.27746610e-04
   -8.10363725e-05  -9.56682150e-05   1.56767723e-04   1.23767807e-04
    2.36667204e-04   1.39588685e-04  -2.95998600e-04   1.47338317e-04
    1.31934555e-04   5.15740715e-05  -1.50849715e-04  -2.22926053e-04
    1.46679431e-04  -1.06175055e-04  -2.52538558e-04   1.56603662e-04
    1.50514883e-04   4.23109252e-05   1.19678905e-04   2.16870152e-05
    2.13604262e-04   8.79059283e-05   1.73624241e-04   1.73048316e-04
   -1.65876119e-04   1.14896819e-04  -2.26929527e-04   6.12553267e-05
    1.35056933e-04  -1.05793233e-04]]
    transform: [[ 1.]
 [ 0.]]
    encoder: [[  6.65493591e+00   2.70610244e+00]
 [  9.53778716e+00  -1.61313409e+00]
 [  4.28386177e+01   1.21563321e+01]
 [  7.17704575e-01  -3.28553473e+00]
 [ -1.53414574e+00  -2.98022322e+00]
 [  1.27119297e+01  -9.82797162e-01]
 [  2.65934563e+00  -7.37891807e+00]
 [  1.56860666e+01  -8.31258331e+00]
 [ -9.11456754e+01  -1.13866649e+02]
 [ -1.78722820e+01  -1.21370075e+01]
 [ -6.68764589e+00  -3.66789304e+01]
 [  2.47692807e+01  -1.86380381e+00]
 [  3.07907386e+01  -1.34054798e+01]
 [  3.24521410e+00  -1.28780642e+01]
 [  1.01409154e+01   4.32586641e+01]
 [ -1.47966539e+01  -4.75341281e+01]
 [  2.38684174e+00   2.78004499e+00]
 [  2.62649598e+01  -2.70859518e+01]
 [ -2.95933518e+00   3.36908017e+00]
 [  5.03458040e+00   1.42777123e+01]
 [ -1.21639346e+01  -6.56259893e+00]
 [  5.28755967e-02   5.34119506e+00]
 [ -8.39177685e+00   4.61070787e+00]
 [  1.34258905e+01   1.12495124e+01]
 [  2.47833499e+01  -2.35418125e+00]
 [ -3.23740906e+00   8.47925006e+00]
 [ -5.95966211e-01  -1.07109984e+01]
 [  3.35829701e+01  -5.84787048e+00]
 [ -4.92521803e-01   4.44110162e+00]
 [ -1.62967599e+01   1.63024729e+01]
 [ -1.67288687e+00  -2.62416686e+00]
 [  6.84394226e+01   1.10161621e+02]
 [ -3.50121303e+00   2.56840491e-01]
 [ -2.93124164e+00   1.21312261e+00]
 [ -2.18641993e+01   1.00823494e+00]
 [  5.33718738e+00  -3.17120808e+00]
 [ -4.48792609e+00  -1.13022429e+01]
 [  1.52055112e+01  -7.84757020e+00]
 [  4.98374238e+00  -6.51428861e+00]
 [ -6.77107814e+00   2.31545353e+00]
 [ -1.12502454e+01  -4.88318430e+00]
 [  1.08531255e+01   1.57515170e+01]
 [ -3.26618034e+00   5.94218897e+00]
 [  1.73644632e+01  -4.32578364e+00]
 [  1.20519627e+02  -3.60014951e+00]
 [  2.78192254e+00  -4.66773955e+00]
 [  5.24633550e+02   3.85214684e+02]
 [  4.78221030e+00  -2.19730758e+00]
 [  2.02831752e+00  -1.37049125e+01]
 [ -3.62134563e+01   1.14049385e+01]
 [  2.61974930e+00   9.51678745e+00]
 [  1.03466118e+01   2.57671006e+00]
 [ -2.72875105e+00   9.76985512e+00]
 [  6.80022058e+00   4.53984137e+00]
 [ -8.01955793e-01  -1.13956024e+01]
 [  7.55656892e+00  -2.03078696e+01]
 [  1.58085242e+01  -2.90869656e+01]
 [ -1.23304736e-01   4.49462993e+00]
 [ -1.12966783e+01   1.88371409e+00]
 [  7.76465177e+00   1.63003751e+01]
 [ -4.09836162e+01  -1.93123726e+01]
 [ -5.81705463e+00  -3.43467630e+00]
 [ -4.69316946e+00  -4.11370662e+00]
 [  2.39797264e+01  -2.07484937e+00]
 [ -2.66122208e+00   2.85141834e+00]
 [ -1.80220207e+02  -4.87415542e+01]
 [  8.07724789e-01  -4.13094132e+00]
 [ -1.25130627e+00  -3.00859471e+00]
 [  3.66682390e+00  -2.93586640e+00]
 [  8.96178774e+00  -1.19893648e+00]
 [ -2.94347498e+01   9.74613789e+00]
 [  1.98037365e+01   6.61397052e+00]
 [ -2.91761460e+00   2.49265195e+01]
 [ -2.62758140e+01  -4.38836586e+00]
 [ -9.99192699e+00  -1.06480706e+01]
 [ -8.47001944e+00  -3.91716646e+01]
 [ -2.92517134e+00   3.79296377e+01]
 [ -4.12744378e+00   4.79676564e+00]
 [  4.59317437e+00  -9.88558054e-01]
 [ -2.15159078e+01  -5.94328027e-01]
 [  3.92514684e+00   5.92245481e+00]
 [ -3.06318845e+01  -2.49990392e+01]
 [  4.64551959e+00  -1.23602962e+02]
 [  1.75103319e+00   9.88953417e+00]
 [ -3.32922262e+00   1.13467905e+00]
 [  4.03734891e+00  -3.62917915e+00]
 [ -6.55975502e+00  -6.70814747e+00]
 [ -8.45124801e+01   3.74468974e+02]
 [  5.78176950e+00   1.39551646e+00]
 [  3.14421102e+02  -3.34652019e+02]
 [  5.98099462e+00   2.68262859e+00]
 [  1.00585445e+00  -2.64280033e+00]
 [ -3.06415161e+00   6.38486447e-01]
 [  3.56710891e+00   1.95020586e+00]
 [  9.32043782e+00   1.10271538e+01]
 [  1.58957079e+01   3.19853572e+00]
 [ -1.93322292e+00  -1.05718562e+01]
 [  5.01471614e+02  -5.89677620e+02]
 [  3.29564031e+00   7.56419588e+00]
 [  4.05813858e+00   1.30099066e+01]
 [ -2.45820952e+01  -6.23946726e-01]
 [ -5.05331039e-01   6.21157967e+00]
 [ -2.40481691e+00   3.56920280e+00]
 [ -1.02694637e+01  -7.64265240e+00]
 [  3.21941777e+00  -2.76309533e+00]
 [ -2.03713179e+01  -1.27578437e+00]
 [ -3.88744574e+00   1.01355245e+01]
 [  1.69473633e+00   3.64434154e+00]
 [ -1.31943244e+01   2.39502431e+00]
 [  1.04565008e+01  -2.08220998e+01]
 [ -5.28667098e+00  -5.67010204e+00]
 [ -6.79671895e+00   2.78968578e+01]
 [ -8.91971946e+00  -1.12214530e+01]
 [  3.89025881e+01  -3.00084059e+01]
 [  9.28646272e-01  -3.87002899e+01]
 [  9.96186346e+00  -1.65918220e+01]
 [ -1.00624401e+01   4.72831469e+00]
 [ -3.94706801e+01  -3.46283345e+01]
 [ -5.10073491e+00  -8.92066925e+00]
 [ -2.46921472e-01   6.63395478e+00]
 [  2.39026442e+01   2.77511665e+01]
 [ -2.37219796e+00  -1.36206585e+00]
 [  4.77928371e+00   2.27952754e+00]
 [ -3.42388819e+00  -6.32414377e-01]
 [  4.31368883e-01  -1.03771048e+01]
 [  3.60389945e+00  -4.19718227e+00]
 [ -4.88194601e+01  -9.39409362e+01]
 [ -1.18483329e+02   5.72271603e+01]
 [  5.59079838e+00   2.63951723e+00]
 [  2.31300162e+01  -3.39006908e+00]
 [ -6.51726515e+00   3.56878144e-01]
 [ -8.62028005e+00   1.75619272e+01]
 [ -6.33117213e+00   1.72281286e+01]
 [ -1.16973298e+01   6.88303193e+00]
 [ -1.36753402e+01   5.19040542e+01]
 [ -7.91368233e+00  -1.33642430e+01]
 [ -1.07288889e+01  -1.48594319e+01]
 [ -5.19733226e+01  -4.15811480e+01]
 [  1.08322104e+01   5.34196117e+00]
 [ -3.46953873e+01   4.25686663e+01]
 [ -1.80226653e+01   1.24065945e+01]
 [  8.30652426e+00   6.05474292e+00]
 [ -9.77491382e-03  -2.21823654e+00]
 [ -3.19395988e+00   3.08542450e+00]
 [  1.27336312e+01   1.76142468e+01]
 [ -1.80557149e+00  -3.77822183e+00]
 [  5.96261095e+01   6.71997678e+01]
 [  4.45134202e+00   1.12008177e-01]
 [  3.79234463e+00  -3.79958934e+00]
 [ -1.63952868e+01  -1.10351480e+01]
 [ -3.95733869e+00  -1.30342568e+01]
 [  2.55795545e+00   8.08087849e-01]
 [ -7.12159836e+00  -1.38145006e+01]
 [ -1.59134595e+00   3.49999626e+00]
 [  5.88867204e-01  -7.62338368e+00]
 [ -1.83207487e+00   4.61272938e+00]
 [  1.47418937e+01  -5.44591737e+00]
 [  1.60070245e+00  -8.57115447e+00]
 [  1.41721624e+01  -1.01725452e+01]
 [ -9.09156664e+00  -1.83878674e+01]
 [ -8.44042395e+00   8.45645113e+00]
 [ -6.92994309e+00   2.31460110e+00]
 [  6.36261653e+00  -3.38202248e+00]
 [  1.09800108e+01  -4.11716302e-01]
 [ -1.15660819e+01  -5.42060557e+00]
 [ -3.92005097e+00  -7.82650855e+00]
 [ -2.18603040e+00   2.39445525e+00]
 [  2.09174007e+01  -8.21017070e-01]
 [  8.93290601e+01  -1.31480158e+01]
 [ -2.41417064e+01  -9.82474991e+00]
 [  3.57406911e+00   1.66819424e+01]
 [  2.84383970e+01  -3.99993144e+01]
 [ -3.44196081e+01  -1.89563738e+01]
 [ -7.10579364e+00   3.69501467e+00]
 [  1.13511349e+01  -2.97350975e+00]
 [  4.19171746e+00  -1.11194784e+00]
 [  4.84249512e-01  -8.04632381e+00]
 [  6.33130401e+01   2.19952994e+01]
 [  3.82769965e+00   1.37970498e+00]
 [ -3.55445348e+03   2.51599085e+03]
 [ -1.12731047e+01   3.05865998e+00]
 [  2.48331443e+00   4.72201241e+00]
 [  3.13103041e+00   3.48342075e+00]
 [  1.30218777e+01   6.25991618e+00]
 [ -2.46684010e+00  -6.17352858e+00]
 [ -4.79718589e+00   3.56156855e+00]
 [  1.21245784e+01   8.87942512e-01]
 [  2.31536075e+00  -8.57661958e+00]
 [  2.89683367e+00  -7.39444516e-01]
 [ -5.22100076e+00  -4.52121778e+00]
 [ -6.84389403e-01  -2.61225506e+00]
 [  1.03422454e+01  -6.79361346e+00]
 [ -2.39970686e+00  -5.46127285e+00]
 [ -3.37831845e+00   3.29750172e+00]
 [  2.52562797e+01   5.92906484e+00]
 [  8.34392408e-01  -1.45572572e+01]
 [  3.00259455e+01   1.75983265e+00]
 [ -1.13892561e+00   6.03537090e+00]
 [  8.34872390e-02  -1.00925893e+01]
 [ -3.49346253e+00   1.00439051e+01]]
Connection from 31828792 to 169475264
    synapse time constant: 0.005
    decoder: [[ -2.42370107e-04   2.02492369e-04   1.47281302e-04  -2.44292186e-05
    7.45623153e-05  -1.10043684e-05  -1.78782722e-04  -2.36794282e-04
    6.73145149e-05   8.70820293e-05   9.90440935e-05  -1.55655418e-04
   -2.01910833e-04   2.73188755e-04   1.15521696e-04  -1.77956935e-04
   -1.23381480e-04  -4.33336167e-05  -7.16875933e-06   8.45874441e-05
   -2.07568372e-04  -1.40984876e-04   7.71351862e-05   7.67909413e-05
   -1.44891508e-04   7.73386431e-05   7.38126198e-05   9.04134631e-05
    2.34486512e-04   1.56287741e-04  -1.44767687e-04   1.36011192e-04
    1.17270957e-04   1.24092100e-04   7.42352422e-05  -1.84779212e-04
   -3.09392870e-04   1.59183414e-04   7.47069238e-05   1.73459138e-04
   -7.82154616e-05   9.10943047e-05  -1.50318026e-04  -1.57160229e-04
    8.22947445e-05  -1.54801171e-04  -2.06344395e-05  -1.53693044e-04
    1.91785070e-04  -4.41785213e-05]]
    transform: [[ 0.]
 [ 1.]]
    encoder: [[  6.65493591e+00   2.70610244e+00]
 [  9.53778716e+00  -1.61313409e+00]
 [  4.28386177e+01   1.21563321e+01]
 [  7.17704575e-01  -3.28553473e+00]
 [ -1.53414574e+00  -2.98022322e+00]
 [  1.27119297e+01  -9.82797162e-01]
 [  2.65934563e+00  -7.37891807e+00]
 [  1.56860666e+01  -8.31258331e+00]
 [ -9.11456754e+01  -1.13866649e+02]
 [ -1.78722820e+01  -1.21370075e+01]
 [ -6.68764589e+00  -3.66789304e+01]
 [  2.47692807e+01  -1.86380381e+00]
 [  3.07907386e+01  -1.34054798e+01]
 [  3.24521410e+00  -1.28780642e+01]
 [  1.01409154e+01   4.32586641e+01]
 [ -1.47966539e+01  -4.75341281e+01]
 [  2.38684174e+00   2.78004499e+00]
 [  2.62649598e+01  -2.70859518e+01]
 [ -2.95933518e+00   3.36908017e+00]
 [  5.03458040e+00   1.42777123e+01]
 [ -1.21639346e+01  -6.56259893e+00]
 [  5.28755967e-02   5.34119506e+00]
 [ -8.39177685e+00   4.61070787e+00]
 [  1.34258905e+01   1.12495124e+01]
 [  2.47833499e+01  -2.35418125e+00]
 [ -3.23740906e+00   8.47925006e+00]
 [ -5.95966211e-01  -1.07109984e+01]
 [  3.35829701e+01  -5.84787048e+00]
 [ -4.92521803e-01   4.44110162e+00]
 [ -1.62967599e+01   1.63024729e+01]
 [ -1.67288687e+00  -2.62416686e+00]
 [  6.84394226e+01   1.10161621e+02]
 [ -3.50121303e+00   2.56840491e-01]
 [ -2.93124164e+00   1.21312261e+00]
 [ -2.18641993e+01   1.00823494e+00]
 [  5.33718738e+00  -3.17120808e+00]
 [ -4.48792609e+00  -1.13022429e+01]
 [  1.52055112e+01  -7.84757020e+00]
 [  4.98374238e+00  -6.51428861e+00]
 [ -6.77107814e+00   2.31545353e+00]
 [ -1.12502454e+01  -4.88318430e+00]
 [  1.08531255e+01   1.57515170e+01]
 [ -3.26618034e+00   5.94218897e+00]
 [  1.73644632e+01  -4.32578364e+00]
 [  1.20519627e+02  -3.60014951e+00]
 [  2.78192254e+00  -4.66773955e+00]
 [  5.24633550e+02   3.85214684e+02]
 [  4.78221030e+00  -2.19730758e+00]
 [  2.02831752e+00  -1.37049125e+01]
 [ -3.62134563e+01   1.14049385e+01]
 [  2.61974930e+00   9.51678745e+00]
 [  1.03466118e+01   2.57671006e+00]
 [ -2.72875105e+00   9.76985512e+00]
 [  6.80022058e+00   4.53984137e+00]
 [ -8.01955793e-01  -1.13956024e+01]
 [  7.55656892e+00  -2.03078696e+01]
 [  1.58085242e+01  -2.90869656e+01]
 [ -1.23304736e-01   4.49462993e+00]
 [ -1.12966783e+01   1.88371409e+00]
 [  7.76465177e+00   1.63003751e+01]
 [ -4.09836162e+01  -1.93123726e+01]
 [ -5.81705463e+00  -3.43467630e+00]
 [ -4.69316946e+00  -4.11370662e+00]
 [  2.39797264e+01  -2.07484937e+00]
 [ -2.66122208e+00   2.85141834e+00]
 [ -1.80220207e+02  -4.87415542e+01]
 [  8.07724789e-01  -4.13094132e+00]
 [ -1.25130627e+00  -3.00859471e+00]
 [  3.66682390e+00  -2.93586640e+00]
 [  8.96178774e+00  -1.19893648e+00]
 [ -2.94347498e+01   9.74613789e+00]
 [  1.98037365e+01   6.61397052e+00]
 [ -2.91761460e+00   2.49265195e+01]
 [ -2.62758140e+01  -4.38836586e+00]
 [ -9.99192699e+00  -1.06480706e+01]
 [ -8.47001944e+00  -3.91716646e+01]
 [ -2.92517134e+00   3.79296377e+01]
 [ -4.12744378e+00   4.79676564e+00]
 [  4.59317437e+00  -9.88558054e-01]
 [ -2.15159078e+01  -5.94328027e-01]
 [  3.92514684e+00   5.92245481e+00]
 [ -3.06318845e+01  -2.49990392e+01]
 [  4.64551959e+00  -1.23602962e+02]
 [  1.75103319e+00   9.88953417e+00]
 [ -3.32922262e+00   1.13467905e+00]
 [  4.03734891e+00  -3.62917915e+00]
 [ -6.55975502e+00  -6.70814747e+00]
 [ -8.45124801e+01   3.74468974e+02]
 [  5.78176950e+00   1.39551646e+00]
 [  3.14421102e+02  -3.34652019e+02]
 [  5.98099462e+00   2.68262859e+00]
 [  1.00585445e+00  -2.64280033e+00]
 [ -3.06415161e+00   6.38486447e-01]
 [  3.56710891e+00   1.95020586e+00]
 [  9.32043782e+00   1.10271538e+01]
 [  1.58957079e+01   3.19853572e+00]
 [ -1.93322292e+00  -1.05718562e+01]
 [  5.01471614e+02  -5.89677620e+02]
 [  3.29564031e+00   7.56419588e+00]
 [  4.05813858e+00   1.30099066e+01]
 [ -2.45820952e+01  -6.23946726e-01]
 [ -5.05331039e-01   6.21157967e+00]
 [ -2.40481691e+00   3.56920280e+00]
 [ -1.02694637e+01  -7.64265240e+00]
 [  3.21941777e+00  -2.76309533e+00]
 [ -2.03713179e+01  -1.27578437e+00]
 [ -3.88744574e+00   1.01355245e+01]
 [  1.69473633e+00   3.64434154e+00]
 [ -1.31943244e+01   2.39502431e+00]
 [  1.04565008e+01  -2.08220998e+01]
 [ -5.28667098e+00  -5.67010204e+00]
 [ -6.79671895e+00   2.78968578e+01]
 [ -8.91971946e+00  -1.12214530e+01]
 [  3.89025881e+01  -3.00084059e+01]
 [  9.28646272e-01  -3.87002899e+01]
 [  9.96186346e+00  -1.65918220e+01]
 [ -1.00624401e+01   4.72831469e+00]
 [ -3.94706801e+01  -3.46283345e+01]
 [ -5.10073491e+00  -8.92066925e+00]
 [ -2.46921472e-01   6.63395478e+00]
 [  2.39026442e+01   2.77511665e+01]
 [ -2.37219796e+00  -1.36206585e+00]
 [  4.77928371e+00   2.27952754e+00]
 [ -3.42388819e+00  -6.32414377e-01]
 [  4.31368883e-01  -1.03771048e+01]
 [  3.60389945e+00  -4.19718227e+00]
 [ -4.88194601e+01  -9.39409362e+01]
 [ -1.18483329e+02   5.72271603e+01]
 [  5.59079838e+00   2.63951723e+00]
 [  2.31300162e+01  -3.39006908e+00]
 [ -6.51726515e+00   3.56878144e-01]
 [ -8.62028005e+00   1.75619272e+01]
 [ -6.33117213e+00   1.72281286e+01]
 [ -1.16973298e+01   6.88303193e+00]
 [ -1.36753402e+01   5.19040542e+01]
 [ -7.91368233e+00  -1.33642430e+01]
 [ -1.07288889e+01  -1.48594319e+01]
 [ -5.19733226e+01  -4.15811480e+01]
 [  1.08322104e+01   5.34196117e+00]
 [ -3.46953873e+01   4.25686663e+01]
 [ -1.80226653e+01   1.24065945e+01]
 [  8.30652426e+00   6.05474292e+00]
 [ -9.77491382e-03  -2.21823654e+00]
 [ -3.19395988e+00   3.08542450e+00]
 [  1.27336312e+01   1.76142468e+01]
 [ -1.80557149e+00  -3.77822183e+00]
 [  5.96261095e+01   6.71997678e+01]
 [  4.45134202e+00   1.12008177e-01]
 [  3.79234463e+00  -3.79958934e+00]
 [ -1.63952868e+01  -1.10351480e+01]
 [ -3.95733869e+00  -1.30342568e+01]
 [  2.55795545e+00   8.08087849e-01]
 [ -7.12159836e+00  -1.38145006e+01]
 [ -1.59134595e+00   3.49999626e+00]
 [  5.88867204e-01  -7.62338368e+00]
 [ -1.83207487e+00   4.61272938e+00]
 [  1.47418937e+01  -5.44591737e+00]
 [  1.60070245e+00  -8.57115447e+00]
 [  1.41721624e+01  -1.01725452e+01]
 [ -9.09156664e+00  -1.83878674e+01]
 [ -8.44042395e+00   8.45645113e+00]
 [ -6.92994309e+00   2.31460110e+00]
 [  6.36261653e+00  -3.38202248e+00]
 [  1.09800108e+01  -4.11716302e-01]
 [ -1.15660819e+01  -5.42060557e+00]
 [ -3.92005097e+00  -7.82650855e+00]
 [ -2.18603040e+00   2.39445525e+00]
 [  2.09174007e+01  -8.21017070e-01]
 [  8.93290601e+01  -1.31480158e+01]
 [ -2.41417064e+01  -9.82474991e+00]
 [  3.57406911e+00   1.66819424e+01]
 [  2.84383970e+01  -3.99993144e+01]
 [ -3.44196081e+01  -1.89563738e+01]
 [ -7.10579364e+00   3.69501467e+00]
 [  1.13511349e+01  -2.97350975e+00]
 [  4.19171746e+00  -1.11194784e+00]
 [  4.84249512e-01  -8.04632381e+00]
 [  6.33130401e+01   2.19952994e+01]
 [  3.82769965e+00   1.37970498e+00]
 [ -3.55445348e+03   2.51599085e+03]
 [ -1.12731047e+01   3.05865998e+00]
 [  2.48331443e+00   4.72201241e+00]
 [  3.13103041e+00   3.48342075e+00]
 [  1.30218777e+01   6.25991618e+00]
 [ -2.46684010e+00  -6.17352858e+00]
 [ -4.79718589e+00   3.56156855e+00]
 [  1.21245784e+01   8.87942512e-01]
 [  2.31536075e+00  -8.57661958e+00]
 [  2.89683367e+00  -7.39444516e-01]
 [ -5.22100076e+00  -4.52121778e+00]
 [ -6.84389403e-01  -2.61225506e+00]
 [  1.03422454e+01  -6.79361346e+00]
 [ -2.39970686e+00  -5.46127285e+00]
 [ -3.37831845e+00   3.29750172e+00]
 [  2.52562797e+01   5.92906484e+00]
 [  8.34392408e-01  -1.45572572e+01]
 [  3.00259455e+01   1.75983265e+00]
 [ -1.13892561e+00   6.03537090e+00]
 [  8.34872390e-02  -1.00925893e+01]
 [ -3.49346253e+00   1.00439051e+01]]
Connection from 169475264 to 169475600
    synapse time constant: 0.005
    decoder: [[  1.96506918e-04  -3.48036551e-05   2.54021001e-04   2.74885908e-05
   -8.07458640e-05  -1.22038439e-05   1.60823950e-04  -2.03172406e-04
    1.36061250e-04   2.43543891e-04   9.93389376e-06  -1.07775148e-05
   -2.22430560e-04  -6.42590152e-05   3.30802495e-05   5.57423663e-05
    9.94621678e-05  -4.49077927e-04  -1.42951588e-04   9.89608917e-05
    1.73792210e-04  -2.38305685e-05  -4.85913189e-05   2.31286930e-05
   -4.65656497e-05  -2.34716441e-04   5.61260098e-05  -1.50356811e-04
   -4.12933161e-05  -3.06701091e-04   6.84211999e-05   4.04915119e-04
   -3.89349385e-05  -2.84218450e-06  -3.14324637e-05   2.33153877e-04
    8.36120548e-05  -8.61898647e-05   1.30651569e-04  -1.69748989e-04
   -2.18639365e-04   1.12218186e-04   8.96736631e-05  -1.20601887e-04
   -7.73002368e-05  -6.31398578e-05   0.00000000e+00   1.59570281e-04
   -6.50633879e-06  -1.08306351e-04   4.06144661e-05   1.00086755e-04
   -1.66323815e-04  -8.07892744e-05   5.31007341e-05  -1.35671123e-04
   -1.68707161e-04  -1.38454116e-05   1.92060602e-05   2.06881907e-04
    5.37638587e-05   1.55106565e-04  -1.78236803e-04   2.92249399e-06
    9.80757710e-05   9.76144464e-05   6.01596975e-05   8.87690210e-05
    9.28601721e-05  -5.44290821e-05  -3.64724880e-04   2.88809560e-04
   -5.43413315e-05   1.15886781e-05   3.27248295e-04   3.96354984e-05
   -3.36047427e-05  -9.11272542e-05  -1.39138620e-05   8.86556512e-06
   -1.43125290e-04   2.02967020e-04  -4.99119883e-05   1.14020056e-04
   -1.09957633e-05  -1.53792597e-04  -4.76087744e-05  -4.04480896e-05
    8.82871311e-05  -1.28176220e-04  -1.45844348e-05   7.37220165e-05
   -4.36112152e-05   6.24913467e-05   2.86598017e-04   1.08855601e-04
   -1.57536893e-05  -6.59581600e-05  -1.52293282e-04   9.40250171e-05
   -6.83656506e-05  -1.95701241e-05   7.60882777e-05   2.42546250e-04
   -1.19668515e-04  -5.60900647e-05  -2.10559736e-04  -6.49229615e-05
   -1.43657852e-04  -2.28475594e-04   2.51721888e-04  -1.73461963e-04
    1.17734659e-04  -1.64813183e-04   5.50443595e-06  -1.74455010e-04
    2.15072845e-04   2.55219503e-04   1.24816282e-04   2.15257663e-06
    4.74221873e-04  -2.00115003e-05   1.75437109e-04   2.78885337e-05
   -1.30511301e-05  -1.34017456e-04   2.66238972e-05  -1.75936308e-04
   -8.35671170e-05  -4.23850031e-05  -8.01899653e-05  -1.08569587e-04
   -1.76577163e-04   2.42511202e-05  -1.57307285e-04   6.78745054e-05
    1.79079837e-04   1.68480614e-04  -1.23798711e-04  -2.34006162e-04
   -3.69397183e-04  -1.73653456e-04   5.42666591e-06  -2.29373110e-05
    1.26378057e-04  -7.32216352e-05   5.34584325e-05   4.77958289e-05
    1.08943924e-04   2.00569006e-04  -1.15733348e-04   1.21680406e-05
    1.02930823e-04   5.06988278e-05  -5.89584584e-06  -7.52000729e-05
   -1.30781096e-04  -2.94644929e-05  -3.08516899e-04   6.63728623e-05
    1.43379465e-04  -2.11329248e-04  -1.55936609e-04  -2.93423919e-06
    1.31315370e-04   1.17109365e-04   2.09225588e-05  -5.01456109e-05
   -1.58692084e-05   1.43805913e-04   1.70339946e-04  -2.88077196e-04
    2.28908517e-04  -1.29067389e-06  -2.37265559e-05   1.06468570e-04
    1.83225811e-05   2.78547562e-04  -2.86132023e-05   0.00000000e+00
   -4.34724482e-05  -1.24993405e-04  -1.14039735e-04   8.58425675e-05
   -1.50699430e-04   1.43349188e-04   5.38256025e-05   1.32707510e-04
    8.60476720e-05  -2.18403685e-04  -3.41868643e-05  -1.70136662e-04
    1.45159985e-05   5.12225748e-05   5.79092690e-05   7.49668733e-06
    8.79493724e-05   1.39109279e-05   2.69123005e-05  -7.93612571e-05]]
    transform: [[ 1.]]
    encoder: [[ -1.57996504e+01]
 [  1.60399525e+01]
 [ -1.93488579e+01]
 [  7.29960950e+00]
 [  1.27901123e+01]
 [  4.67333846e+00]
 [  2.09505697e+01]
 [  4.68666019e+01]
 [  1.42191553e+01]
 [ -1.90579984e+01]
 [  2.53543583e+01]
 [  5.62728256e+00]
 [  3.91574570e+02]
 [ -6.22525056e+03]
 [ -1.36967570e+01]
 [ -3.14545836e+01]
 [ -1.09319829e+01]
 [ -1.42697619e+01]
 [ -1.40865443e+01]
 [  8.59575492e+00]
 [  1.29250124e+01]
 [  1.48217466e+01]
 [  1.43080527e+01]
 [  5.55839601e+00]
 [ -2.19978445e+01]
 [ -1.80045580e+01]
 [  1.11552135e+01]
 [  1.17664270e+01]
 [  3.67617748e+02]
 [ -1.15251530e+01]
 [  1.81219516e+01]
 [  9.09730739e+00]
 [ -9.00608016e+00]
 [  4.38769436e+01]
 [ -1.04498973e+01]
 [  6.33678165e+00]
 [  8.29285207e+00]
 [ -5.93174476e+01]
 [  8.81066866e+00]
 [ -9.15016395e+01]
 [  2.58885920e+01]
 [ -1.18106453e+01]
 [  1.01779320e+01]
 [ -9.71740036e+00]
 [  1.06781666e+01]
 [  1.53858787e+01]
 [  1.51198949e+02]
 [  5.65832691e+00]
 [ -9.01323521e+00]
 [ -2.57648539e+01]]

Step 7: Extract data about inputs


In [8]:
for conn in model.all_connections:
    if isinstance(conn.pre_obj, nengo.Node) and isinstance(conn.post_obj, nengo.Ensemble):
        print('Connection from input %d to %d' % (id(conn.pre_obj), id(conn.post_obj)))
        print('    synapse time constant: %g' % conn.synapse.tau)        
        transform = nengo.utils.builder.full_transform(conn, allow_scalars=False)
        encoder = sim.data[conn.post_obj].scaled_encoders
        print('    transform: %s' % transform)
        print('    encoder: %s' % encoder)


Connection from input 169474592 to 54978880
    synapse time constant: 0.005
    transform: [[ 1.]]
    encoder: [[  -9.76827208]
 [  -6.02814891]
 [ 197.83912915]
 [ -10.14439215]
 [   6.52682433]
 [  26.05899661]
 [ -11.26967343]
 [ -30.07881565]
 [  -6.37904379]
 [ 187.64486175]
 [ -34.26702021]
 [  -9.09819384]
 [   7.86515966]
 [  15.34816994]
 [ -10.57105725]
 [ -17.06405338]
 [ -25.72071465]
 [ -38.2402476 ]
 [  -5.26423124]
 [   9.44622906]
 [-196.27778354]
 [ -11.87655947]
 [  16.04232069]
 [   5.46286115]
 [  69.8177485 ]
 [   7.79895678]
 [ -16.67994583]
 [  53.12247335]
 [   6.38714938]
 [ 104.06781792]
 [ -32.93703656]
 [  -7.02124523]
 [   7.21535806]
 [ -12.69695178]
 [ -12.21956146]
 [   9.51982899]
 [   8.07007305]
 [ 364.45594139]
 [  46.00438214]
 [ 140.79373454]
 [   9.04913851]
 [  16.11824636]
 [   6.46717367]
 [  12.34391846]
 [-128.99708974]
 [   5.28396728]
 [  -8.3766421 ]
 [  29.294484  ]
 [   6.3648384 ]
 [ -14.35856558]]
Connection from input 7571104 to 31828792
    synapse time constant: 0.005
    transform: [[ 1.]]
    encoder: [[  -35.96502588]
 [   15.93368085]
 [    8.61720022]
 [  -82.65974951]
 [    6.56163249]
 [ -730.945238  ]
 [   -6.68367003]
 [  -12.01938153]
 [    6.04500366]
 [    9.17719123]
 [   28.0360552 ]
 [   -9.76236521]
 [  -29.38777902]
 [   76.74901889]
 [    6.45816068]
 [  -27.38246972]
 [  -12.27776943]
 [ -351.90798105]
 [-1583.62018103]
 [   12.20099572]
 [  -13.56613549]
 [ -107.79911161]
 [    4.38571629]
 [   17.17822184]
 [  -32.01974845]
 [   25.85456512]
 [  201.00925876]
 [    9.73116259]
 [   20.77093689]
 [   13.9366952 ]
 [  -10.64726124]
 [   23.78771519]
 [   11.10036944]
 [    6.55431528]
 [    7.47366491]
 [   -4.25480376]
 [  -12.37554941]
 [   82.49547038]
 [   16.42868542]
 [   15.10689243]
 [ -194.9227481 ]
 [    9.27162178]
 [   -7.22438633]
 [  -21.26944957]
 [  229.0546045 ]
 [  -13.57552838]
 [ -142.98832697]
 [   -4.00432954]
 [   14.49376606]
 [  -59.44131859]]

Step 8: Extract data about outputs:


In [9]:
for conn in model.all_connections:
    if isinstance(conn.pre_obj, nengo.Ensemble) and isinstance(conn.post_obj, nengo.Node):
        print('Connection from %d to output %d' % (id(conn.pre_obj), id(conn.post_obj)))
        print('    synapse time constant: %g' % conn.synapse.tau)
        decoder = sim.data[conn].weights
        transform = nengo.utils.builder.full_transform(conn, allow_scalars=False)
        print('    decoder: %s' % decoder)
        print('    transform: %s' % transform)


Connection from 169475600 to output 169475768
    synapse time constant: 0.03
    decoder: [[ -1.48053450e-04   1.28126240e-04  -2.73442492e-04   8.99790713e-05
    1.19622892e-04   8.77994864e-05   1.04686027e-04   1.40789285e-04
    1.18880505e-04  -1.78032888e-04   1.38440083e-04   9.19944786e-05
    4.91674560e-05  -1.07879808e-05  -1.55722499e-04  -2.01868835e-04
   -1.11416040e-04  -1.47526334e-04  -1.03399397e-04   1.03226100e-04
    1.16099957e-04   1.15469191e-04   1.01985062e-04   9.05788035e-05
   -1.15099098e-04  -1.19940757e-04   1.40683428e-04   1.05237173e-04
    8.80772107e-06  -1.10314066e-04   1.07537114e-04   9.66150194e-05
   -1.52785766e-04   9.13238226e-05  -1.39711902e-04   9.71650505e-05
    9.07523917e-05  -1.19987722e-04   1.05571490e-04  -1.43404268e-04
    2.12816037e-04  -3.16001159e-04   1.17057221e-04  -1.29543671e-04
    9.37569930e-05   1.21675271e-04   1.97056439e-04   9.28029690e-05
   -2.76812285e-04  -1.52502587e-04]]
    transform: [[ 1.]]

Export the data to some simulator

In theory, the above information is all that is needed to run the model. The neurons are all LIF neurons with the stated refractory period, membrane time constant, and background input. They are scaled such that their reset voltage is 0 and their firing threshold is 1.0.

For connections, the code above gives a set of matrices. The actual connection weight matrix is defined by multiplying those matrices together. You can either implement them as a sequence of matrices (if your simulator supports this), or you can multiply them together to get a full weight matrix. For example, for the Connections between ensembles, you would do np.dot(encoder, np.dot(transform, decoder)).

For inputs to the system, the input Node generally has a function. This function should be called, passing in the current time since the beginning of the simulation (in seconds) as t. The result is the value that should be fed into the inputs to the neurons (after multiplying by the transform and the encoder).

For outputs from the system, the activity of all the neurons is multiplied by the decoder and the transform, resulting in a value x. This value (and t) is passed into the output node's function. Note that a Node can act as both input and output.

Each Connection also has a synapse value. This is an exponential filter that should be applied with the provided time constant.

Extra tidbits

The above considerations are enough to run this particular Nengo model, but there are a few things missing that may appear in other Nengo models

  • Probes are helpers that act a lot like output Nodes, but automatically gather data in the same way as the output_function in the above example. Instead of making the output Node in that above example, we could also have just done this and gotten the equivalence result:
with model:
    probe_d = nengo.Probe(d)
sim = nengo.Simulator(model)
sim.run(1)
pylab.plot(sim.data[probe_d])
  • You can have Nodes that act as both outputs and inputs
with model:
    def in_and_out_function(t, x):
        return x[0] * x[2], x[1]
    my_node = nengo.Node(in_and_out_function, size_in=3, size_out=2)
  • You can also chain more than one transform together. This is done by using Nodes that have None as their function. So the following two networks would give the identical results:
with model:
    a = nengo.Ensemble(50, 1)
    b_dummy = nengo.Node(None, size_in=1)
    c_dummy = nengo.Node(None, size_in=1)
    d = nengo.Ensemble(50, 1)
    nengo.Connection(a, b_dummy, transform=[[1.0]])
    nengo.Connection(b_dummy, c_dummy, transform=[[2.0]])
    nengo.Connection(c_dummy, d, transform=[[3.0]])
with model:
    a = nengo.Ensemble(50, 1)
    d = nengo.Ensemble(50, 1)
    nengo.Connection(a, d, transform=[[6.0]])
  • Connections can have LearningRules, and a Connection that connects into a Learning Rule is used to provide the modulatory signal for the learning rule (such as an error signal)

In [ ]: